/**
 * 解析圈子列表
 */
package cn.suse.android.logic;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import cn.suse.android.entity.Group;

import android.R.integer;

/**
 * @author liubin
 * Create DateTime:Oct 16, 2012 5:11:02 PM
 * Description:
 * @Version: 1.0.0
 */
public class GroupParse extends BaseParse<Group> {

	/* (non-Javadoc)
	 * @see cn.suse.android.logic.BaseParse#parseData(java.lang.String)
	 */
	@Override
	public List<Group> parseData(String content) {
		// TODO Auto-generated method stub
		List<Group> lists = new ArrayList<Group>();
		try {
			JSONObject jsonObject = new JSONObject(content);
			JSONArray jsonArray = jsonObject.getJSONArray("data");
			for(int i = 0;i<jsonArray.length();i++){
				JSONObject jObject = jsonArray.getJSONObject(i);
				Group group = new Group();
				group.setCatalog(jObject.getString("catalog"));
				group.setGid(jObject.getString("gid"));
				group.setName(jObject.getString("name"));
				lists.add(group);
			}
		} catch (JSONException e) {
			e.printStackTrace();
			return lists;
		}
		return lists;
	}

}
